package ofxdownloader;

/**
 * Container class for credit card account information retrieved from an OFX response
 * @author Alex Spurling
 * @author Chris Thornton
 *
 */
public class CCAccount extends Account {

	public CCAccount(String description, String accountID ) {
		this.description = description;
		this.accountID = accountID;
		this.accountType = "Credit Card";
	}

	@Override
	public boolean equals(Object other) {
		if (other instanceof CCAccount) {
			CCAccount otherAcc = (CCAccount)other;
			return (description.equals(otherAcc.getDescription()) &&
					accountID.equals(otherAcc.getAccountID()));
		}
		return false;
	}

	@Override
	public int hashCode() {
		return description.hashCode() + accountID.hashCode();
	}

	public String getAccountOFXRequest(String ID, String fromDateTag, String toDateTag) {

		return
		"<CREDITCARDMSGSRQV1>\n" +
		"<CCSTMTTRNRQ>\n" +
		"<TRNUID>" + ID + "\n" +
		"<CCSTMTRQ>\n" +
		"<CCACCTFROM>\n" +
		"<ACCTID>" + accountID + "\n" +
		"</CCACCTFROM>\n" +
		"<INCTRAN>\n" +
		fromDateTag +
		toDateTag +
		"<INCLUDE>Y\n" +
		"</INCTRAN>\n" +
		"</CCSTMTRQ>\n" +
		"</CCSTMTTRNRQ>\n" +
		"</CREDITCARDMSGSRQV1>\n";

	}

}